<?php

namespace App\Models;

use App\Observers\BrokerObserver;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Undocumented class
 * @name zf
 */
class Borker extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $table = 'zfm_brokers';
    protected $guarded = [];

    /**
     * 经纪人信息展示
     * @return mixed
     */
    public static function list($where, $paginate)
    {
        return self::where($where)->paginate($paginate);
    }

    /**
     * 经纪人信息查找
     * @param $where
     * @return mixed
     */
    public static function Seek($field, $where)
    {
        return self::where($field, 'like', "%$where%")->get();
    }

    /**
     * 经纪人信息删除
     */
    public static function del($where, $fangId)
    {
        return self::where([$where => $fangId])
            ->delete();
    }

    /**
     * 经纪人详情信息
     */
    public static function detail($where)
    {
        return self::where($where)->first();
    }

    /**
     * 经纪人信息修改
     */
    public static function change($field,$BorkerID,$SecondaryMessageUpdated){
        $update= self::where($field,$BorkerID,$BorkerID)->first();
        return $update->fill($SecondaryMessageUpdated)
        ->save();

    }
    public static function boot()
    {
        parent::boot();
        self::observe(BrokerObserver::class);
    }
}
